﻿         using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WcfServer.Classes.Utility;

namespace WcfServer.Classes.Server
{
    [Serializable]
    public class UserResponse
    {
        public string SenderID { set; get; }
        public string ReceiverID { set; get; }
        public string SenderIP { set; get; }
        public string ReceiverIP { set; get; }
        public DateTime TimeStamp { set; get; }
        public byte[] SessionKey { set; get; }

        public UserResponse(byte[] data, byte[] key)
        {
            byte[] temp = Utility.EncryptionHandler.DecryptAES(data, key);
            var ur = SerializerHandler<UserResponse>.DeSerializeInput(temp);
            this.ReceiverID = ur.ReceiverID;
            this.ReceiverIP = ur.ReceiverIP;
            this.SenderID = ur.SenderID;
            this.SenderIP = ur.SenderIP;
            this.SessionKey = ur.SessionKey;
            this.TimeStamp = ur.TimeStamp;
        }
        public UserResponse()
        {

        }
        public byte[] Send(byte[] key)
        {
            var ur = SerializerHandler<UserResponse>.SerializeInput(this);
            return EncryptionHandler.EncryptAES(ur, key);
        }
    }
}
